<!--#
layout("/layouts/platform.html"){
#-->
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/platform/shop/area/management" id="goBack" data-pjax><i class="ti-angle-left"></i>${msg['globals.button.back']}</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="editForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/shop/area/management/editDo" method="post">
                <input name="id" type="hidden" value="${obj.id}">
                <input type="hidden" id="areaCode" value="" name="areaCode">
                <div class="row mb10 mt10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label for="code" class="col-sm-2 control-label">${msg['shop.area.management.column.code']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="code" class="form-control" name="code" data-parsley-required="true"
                                       placeholder="${msg['shop.area.management.column.code']}" value="${obj.code}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">${msg['shop.area.management.column.name']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="name" class="form-control" name="name" data-parsley-required="true"
                                       placeholder="${msg['shop.area.management.column.name']}" value="${obj.name}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="area" class="col-sm-2 control-label">${msg['shop.area.management.column.area']}</label>
                            <div class="col-sm-8">
                                <!--#
                                  for(area in areaList){
                                        var checked = 0;
                                       for(code in areaCodeArray){
                                             if(code == area.code){
                                                 checked = 1;
                                                 break;
                                              }
                                       }
                                     if(checked == 1){#-->
                                <input type="checkbox" value="${area.name}" id="area"  data-id="${area.code}" class="area" name="area" checked/>${area.name}
                                <!--#   }else{#-->
                                <input type="checkbox" value="${area.name}" id="area" data-id="${area.code}" class="area" name="area"/>${area.name}
                                <!--#     }
                            }
                          #-->
                            </div>
                        </div>

                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button id="save" type="submit" class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="${msg['globals.button.submit.tip']}">${msg['globals.button.submit']}</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>

    </div>
</div>
<script language="JavaScript">
    $(document).ready(function () {
        $("#save").on("click",function () {
            var areaCode = "";
            $(".area").each(function (index,obj) {
                if ($(obj).is(':checked')){
                    areaCode += $(obj).attr("data-id")+",";
                }
            })
            areaCode = areaCode.substring(0,areaCode.length-1);
            $("#areaCode").val(areaCode);
            $('#editForm').submit();
        });
        $('#editForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    setTimeout(function () {
                        $("#goBack").trigger("click");
                    }, 1000);
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
    });
</script>
<!--#}#-->